package org.blueoxygen.kukuruyuk.action.masterreceipedetail;

import java.util.ArrayList;
import java.util.List;
import org.blueoxygen.cimande.persistence.PersistenceAware;
import org.blueoxygen.cimande.persistence.PersistenceManager;
import org.blueoxygen.cimande.security.SessionCredentials;
import org.blueoxygen.cimande.security.SessionCredentialsAware;
import org.blueoxygen.kukuruyuk.entity.MasterReceipeDetail;
import org.blueoxygen.kukuruyuk.entity.PurchaseOrder;
import org.blueoxygen.kukuruyuk.entity.Item;
import com.opensymphony.xwork2.ActionSupport;

public class MasterReceipeDetailForm extends ActionSupport
implements PersistenceAware, SessionCredentialsAware {
     protected PersistenceManager manager;
     protected SessionCredentials sessionCredentials;
     private MasterReceipeDetail masterreceipedetail = new MasterReceipeDetail();
     private List<MasterReceipeDetail> masterreceipedetails = new ArrayList<MasterReceipeDetail>();
     
     private PurchaseOrder po = new PurchaseOrder();
     private List<PurchaseOrder> pos = new ArrayList<PurchaseOrder>();
     
     private Item item = new Item();
     private List<Item> items = new ArrayList<Item>();

     public String execute(){
          if(getMasterreceipedetail().getId() != null &&
                  !"".equalsIgnoreCase(getMasterreceipedetail().getId().trim())){
              setMasterreceipedetail((MasterReceipeDetail) manager.getById(MasterReceipeDetail.class, getMasterreceipedetail().getId()));    
          }
          if(getPo().getId() != null &&
                  !"".equalsIgnoreCase(getPo().getId().trim())){
              setPo((PurchaseOrder) manager.getById(PurchaseOrder.class, getPo().getId()));    
          }
          setItems(manager.findAllSorted(Item.class,"id"));
          
          return SUCCESS;
     }
     public void setPersistenceManager(PersistenceManager persistenceManager){
          this.manager = persistenceManager;
     }
     public void setSessionCredentials(SessionCredentials sessionCredentials){
          this. sessionCredentials = sessionCredentials;
     }
     
     
     
     public MasterReceipeDetail getMasterreceipedetail() {
          return masterreceipedetail;
     }
     public void setMasterreceipedetail(MasterReceipeDetail masterreceipedetail) {
       this.masterreceipedetail = masterreceipedetail;
   }
   public List<MasterReceipeDetail> getmasterreceipedetails() {
       return masterreceipedetails;
   }
   public void setMasterreceipedetails(List<MasterReceipeDetail> masterreceipedetails) {
       this.masterreceipedetails = masterreceipedetails;
   }
   
   
   public PurchaseOrder getPo() {
       return po;
   }
   public void setPo(PurchaseOrder po) {
       this.po = po;
   }
   public List<PurchaseOrder> getPos() {
    return pos;
   }
   public void setPos(List<PurchaseOrder> pos) {
    this.pos = pos;
   }

    
    public Item getItem() {
        return item;
    }
    public void setItem(Item item) {
        this.item = item;
    }
    public List<Item> getItems() {
     return items;
    }
    public void setItems(List<Item> items) {
     this.items = items;
   }
}